﻿using BCCommon.Enums;
using BCEntity.TMS.NotificationMessageRecord;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace BCData.TMS.NotificationMessageRecord
{
    /// <summary>
    /// 通知消息记录 (禁止启动事务)
    /// </summary>
    public interface INotificationMessageRecordData
    {
        Task<NotificationMessageRecordEntity> GetNotificationMessageRecordAsync(long notificationMessageId);

        Task<(IEnumerable<NotificationMessageRecordEntity>, int)> GetAdminMessagesAsync(long adminId, bool? isRead, NotificationMessageRecordType? notificationMessageRecordType, int pageIndex, int pageSize);

        Task<(IEnumerable<NotificationMessageRecordEntity>, int)> GetUserMessagesAsync(long userId, bool? isRead, NotificationMessageRecordType? notificationMessageRecordType, int pageIndex, int pageSize);

        Task<int> GetAdminUnreadCountAsync(long adminId);

        Task<int> GetUserUnreadCountAsync(long userId);

        Task<IEnumerable<NotificationGroupMessageCountEntity>> GetAdminGroupUnreadCountAsync(long adminId);

        Task<IEnumerable<NotificationGroupMessageCountEntity>> GetUserGroupUnreadCountAsync(long userId);

        Task<NotificationMessageRecordEntity> InsertAsync(NotificationMessageRecordEntity entity);

        Task<int> InsertAllAsync(IEnumerable<NotificationMessageRecordEntity> entities);

        /// <summary>
        /// 修改消息读取状态
        /// </summary>
        /// <param name="notificationMessageId">通知消息Id</param>
        /// <returns></returns>
        Task<NotificationMessageRecordEntity> UpdateReadStatus(long notificationMessageId);

        /// <summary>
        /// 根据类型批量更改消息读取状态
        /// </summary>
        /// <param name="adminId"></param>
        /// <param name="notificationType"></param>
        /// <returns></returns>
        Task<bool> UpdateBatchIsRead(long adminId, NotificationMessageRecordType? notificationType);

        /// <summary>
        /// 更新通知消息为已处理
        /// </summary>
        /// <param name="notificationMessageId">通知消息Id</param>
        /// <param name="handledRemark">处理备注</param>
        /// <returns></returns>
        Task<NotificationMessageRecordEntity> UpdateIsHandled(long notificationMessageId, string handledRemark);
    }
}